/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ui.components.modeltabele;

import domen.Korisnik;
import java.util.HashMap;
import javax.swing.table.AbstractTableModel;
import model.StorageBroker;

/**
 *
 * @author Vlada
 */
public class KorisniciModelTabele extends AbstractTableModel {

    
    StorageBroker sb;
    Korisnik k;
    HashMap<String, Object> mapa;
    int brojRedova;

    public KorisniciModelTabele() {
       
        k = new Korisnik();
        sb = new StorageBroker(k);

    }

    @Override
    public int getRowCount() {
        return sb.prikaziEntiteteIzMape().size();
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {

        mapa =  sb.prikaziEntiteteIzMape();
        
        Object[] objects = new Object[mapa.size()];
        mapa.keySet().toArray(objects);
        String key = (String) objects[rowIndex];
        Korisnik value = (Korisnik) mapa.get(key);

        if (columnIndex == 0) {
            return value.getIme();
        }
        if (columnIndex == 1) {
            return value.getPrezime();
        }
        if (columnIndex == 2) {
            return value.getEmail();
        }
        if (columnIndex == 3) {
            return value.getKorisickoIme();
        }
        return "N/a";
    }

    @Override
    public String getColumnName(int i) {
        switch (i) {
            case 0:

                return "Ime";
            case 1:
                return "Prezime";
            case 2:
                return "Email";
            case 3:
                return "Korisnicko Ime";
            default:
                return "Nedefinisana Kolona";
        }

    }

    @Override
    public boolean isCellEditable(int row, int column) {
//        if (column == 0 || column == 1) {
//            return true;
//        }

        return false;
    }




}
